#pragma once
#include "sound_out.hpp"
#include <cmath>

template <typename Generator>
class SinSynth
{
public:
    SinSynth();
    float operator()();
private:
    Generator in_;
    float accumulator_;
};

template <typename Generator>
SinSynth<Generator>::SinSynth():
    accumulator_(0)
{}

template <typename Generator>
float SinSynth<Generator>::operator()()
{
    accumulator_ += 2 * 3.1415926 * in_() / SAMPLE_RATE;
    if (accumulator_ > 2 * 3.1415926)
        accumulator_ -= 2 * 3.1415926;
    return sin(accumulator_);
}
